﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;

namespace NX5Web
{
    public partial class wss : System.Web.UI.Page
    {
        public class Drawrsp
        {
            public String Url { set; get; }
        }
        protected async void Page_Load(object sender, EventArgs e)
        {
            var client = new HttpClient();
            var url = "https://nx5.abc5g.com/apis/Doubao/AIDraw"; // 替换为你的API URL
            var jsonData = new { prompt = "卡通风格画面中，一座红色尖顶的学校大厅前，两个戴着红领巾的小学生正合力将一面五星红旗升上 白色旗杆。天空是淡蓝色的，飘着几朵白云，大厅门口挂着一条写有“欢迎”字样的彩色横幅，旁边站着几位微笑的老师和同学，整体场景充满欢乐的校园氛围。" }; // 你的JSON数据
            var json = JsonConvert.SerializeObject(jsonData); // 将对象序列化为JSON字符串
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            String Media = "";
            HttpResponseMessage response = await client.PostAsync(url, content);


            if (response.IsSuccessStatusCode)
            {
                string responseBody = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseBody);
                Drawrsp drp = Newtonsoft.Json.JsonConvert.DeserializeObject<Drawrsp>(responseBody);
                Console.WriteLine(responseBody);

                Media = drp.Url;
            }
            else
            {
                Console.WriteLine($"Error: {response.StatusCode}");
            }
            Console.ReadLine();
        }
    }
}